/**
 * 
 */
package com.hww.DesignPattern.Singleton;

/**
 * @author:Huangwenwei
 * @date:2014-6-18
 * @time:下午8:46:47
 */
public class SingletonTest {

	/**
	 * @Time:下午8:46:47
	 * @Data:2014-6-18
	 * @Email:mr.huangwenwei@gmail.com
	 * @param args
	 * @Return:void
	 */
	public static void main(String[] args) {
		SingletonA a1 = SingletonA.getInstance();
		SingletonA a2 = SingletonA.getInstance();
		System.out.println("用SingletonA实现单例模式");
		System.out.println("调用nextID前：");
		System.out.println("a1.id=" + a1.getId());
		System.out.println("a2.id=" + a2.getId());
		a1.nextID();
		System.out.println("调用nextID后：");
		System.out.println("a1.id=" + a1.getId());
		System.out.println("a2.id=" + a2.getId());

		SingletonB b1 = SingletonB.getInstance();
		SingletonB b2 = SingletonB.getInstance();
		System.out.println("用SingletonA实现单例模式");
		System.out.println("调用nextID前：");
		System.out.println("b1.id=" + b1.getId());
		System.out.println("b2.id=" + b2.getId());
		b1.nextID();
		System.out.println("调用nextID后：");
		System.out.println("b1.id=" + b1.getId());
		System.out.println("b2.id=" + b2.getId());

	}

}
